/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Common;

import java.io.Serializable;
import java.util.Objects;

/**
 *
 * @author Lab-214-21
 */
public class Detail implements Serializable  {
    
    public EmailDetail emailDetail;
    public EmailStatusDetail emailStatusDetail;

    public Detail() {
    }

    public Detail(EmailStatusDetail emailStatusDetail) {
        this.emailStatusDetail = emailStatusDetail;
    }

    public Detail(EmailDetail emailDetail, EmailStatusDetail emailStatusDetail) {
        this.emailDetail = emailDetail;
        this.emailStatusDetail = emailStatusDetail;
    }
    
    public Detail(String subject, String body) {
        this.emailDetail = new EmailDetail(subject, body);
        this.emailStatusDetail = new EmailStatusDetail(EmailStatusType.NEW);
    }
    
    @Override
    public String toString()
   {
       return emailStatusDetail.getMessageStatusAsString() + emailDetail.getEmailContent();
    }
    
    public void updateEmailDetail(String subject, String body) {
        emailDetail = new EmailDetail(subject, body);
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 31 * hash + Objects.hashCode(this.emailStatusDetail);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Detail other = (Detail) obj;
        return Objects.equals(this.emailStatusDetail, other.emailStatusDetail);
    }
    public void updateEmailStatus(EmailStatusType emailStatusType) {
        emailStatusDetail.updateEmailStatus(emailStatusType);
    }
    public EmailStatusType retrieveEmailCurrentStatus() {
        return emailStatusDetail.retrieveEmailCurrentStatus();
    }

    public EmailDetail getEmailDetail() {
        return emailDetail;
    }

    public void setEmailDetail(EmailDetail emailDetail) {
        this.emailDetail = emailDetail;
    }

    public EmailStatusDetail getEmailStatusDetail() {
        return emailStatusDetail;
    }

    public void setEmailStatusDetail(EmailStatusDetail emailStatusDetail) {
        this.emailStatusDetail = emailStatusDetail;
    }
    
}
